home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 1 / The Arsenal Files (Arsenal Computer).ISO / archive / unixarc.pt1 < prev    next >
Internet Message Format  |  1994-01-23  |  49KB

  1. From pacbell!ames!mailrus!uwmcsd1!bbn!bbn.com!rsalz Fri Jul  1 13:09:02 1988
  2. From: rsalz@uunet.uu.net (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v15i077:  ARC (PC compression program), v5.21, Part01/05
  5. Message-ID: <965@fig.bbn.com>
  6. Date: 1 Jul 88 20:09:02 GMT
  7.  
  8. Submitted-by: hyc@math.lsa.umich.edu
  9. Posting-number: Volume 15, Issue 77
  10. Archive-name: arc5.21/part01
  11.  
  12. [  Howard Chu did a lot of work cleaning this up, porting it, and in
  13.    general making it reasonable.  Some work will be needed for SystemV;
  14.    I mailed Howard a copy of the missing routines, so perhaps whoever
  15.    gets to him first will be able to get it from him.  John Gilmore
  16.    made a tremendous effort in contacting Thom Henderson and figuring
  17.    out what the legal obligations are to post this as NON SHAREWARE
  18.    to Usenet.  Please take note of those two words:   ^^^ ^^^^^^^^^.
  19.    Thanks to both of them (Howard and John, not the words :-).  --r$ ]
  20.  
  21. #--------------------------------CUT HERE-------------------------------------
  22. #! /bin/sh
  23. #
  24. # This is a shell archive.  Save this into a file, edit it
  25. # and delete all lines above this comment.  Then give this
  26. # file to sh by executing the command "sh file".  The files
  27. # will be extracted into the current directory owned by
  28. # you with default permissions.
  29. #
  30. # The files contained herein are:
  31. #
  32. # -rw-r--r--  1 hyc          2269 Jun 18 03:39 Read.me
  33. # -rw-rw-rw-  1 hyc          4064 Jun 13 04:32 Readme.too
  34. # -rw-r--r--  1 hyc          2413 Jun 18 03:42 Manifest
  35. # -rw-r--r--  1 hyc          1323 Jun  2 00:43 Make.tws
  36. # -rw-r--r--  1 hyc          2644 Jun 18 03:36 Makefile
  37. # -rw-r--r--  1 hyc          1892 May 14  1987 Changes.521
  38. # -rw-r--r--  1 hyc          5577 Apr 11 19:15 Arcinfo
  39. # -rw-r--r--  1 hyc         18327 Jun 13 04:09 Sysvarcstuf
  40. # -rw-r--r--  1 hyc          2985 Jun 13 13:40 tws.h
  41. #
  42. echo 'x - Read.me'
  43. if test -f Read.me; then echo 'shar: not overwriting Read.me'; else
  44. sed 's/^X//' << '________This_Is_The_END________' > Read.me
  45. XHello again,
  46. X    herein you should be pleased to find the complete sources for the
  47. Xlatest and greatest version of ARC, based on the sources for version 5.21
  48. Xof the MSDOS ARC program. The patches to the previous release, 5.12, with
  49. Xsquashing algorithm, have also been applied here. The code is known to
  50. Xwork on a Sun 3 running SunOS 3.4, Apollo DN3000 running SR9.7 DOMAIN/IX,
  51. XVax 750 running 4.3BSD, and IBM 3090 running MTS. It is also now working
  52. Xon Atari STs, as well as Apollo DN3000 running SR10 DOMAIN/OS (Beta).
  53. X
  54. X    Also included is a detailed description of the format of a .ARC
  55. Xfile directory entry, in the file named Arcinfo. Could be useful if you're
  56. Xtrying to port ARC to any more esoteric systems...
  57. X
  58. X    Jon Zeeff has sent along some code he used to get this working on
  59. XSys V style machines. Looks like scandir is all that's really missing. I
  60. Xhaven't tried any of it out for myself yet, but the code is in the file
  61. X"Sysvarcstuf" should you need it.
  62. X
  63. X    One final necessary inclusion: sources for libtws.a, which was
  64. Xposted a long time ago to mod.sources as part of a package he called
  65. X"phoon" - a program that calculated and displayed the PHase of the mOON.
  66. XThe only thing I use the time routines for here is to convert an expanded
  67. Xdate/time back into a Unix style time value, for keeping file modification
  68. Xtimes straight.
  69. X
  70. X    Thanks to Leo Wilson (leo@cs.buffalo.edu) for sending his copy of
  71. Xa man page for ARC. I've updated it for this version, and included it here
  72. Xas well.
  73. X
  74. X    The default value of the (I)mage mode flag has changed. ARC will
  75. Xnow treat files as binary files, unless the 'i' flag is given. Handling of
  76. XCarriage Returns has been improved a bit. ARC is now a little smarter about
  77. Xtemporary files as well.
  78. X
  79. XTo compile all this stuff... Edit Make.tws (shouldn't need to change anything
  80. Xhere, really.) Edit arc.h. After that, just type make and wait a while...
  81. X(Oh yeah - there's a few makefile macros that need redefining for Atari ST...)
  82. XOk... Well, I've had this for a while, and it works for me, but if somehow
  83. XI've goofed, let me know.
  84. X    
  85. X  /
  86. X /_ , ,_.                      Howard Chu
  87. X/ /(_/(__                University of Michigan
  88. X    /           Computing Center          College of LS&A
  89. X   '              Unix Project          Information Systems
  90. ________This_Is_The_END________
  91. if test `wc -c < Read.me` -ne     2269; then
  92.     echo 'shar: Read.me was damaged during transit (should have been     2269 bytes)'
  93. fi
  94. fi        ; : end of overwriting check
  95. echo 'x - Readme.too'
  96. if test -f Readme.too; then echo 'shar: not overwriting Readme.too'; else
  97. sed 's/^X//' << '________This_Is_The_END________' > Readme.too
  98. XNotes for ARC 5.21                                        June 6, 1988
  99. XThis program is based on the MSDOS ARC program, version 5.21, plus
  100. Xa few enhancements... 
  101. X o ARC also performs Huffman Squeezing on data. The Huffman Squeeze
  102. X   algorithm was removed from MSDOS ARC after version 5.12. It turns
  103. X   out to be more efficient than Lempel-Ziv style compression when
  104. X   compressing graphic images. Squeeze analysis is always done now,
  105. X   and the best of packing, squeezing, or crunching is used.
  106. X o Compresses and extracts Squashed files. "Squashing" was created
  107. X   by Phil Katz in his PKxxx series of ARC utility programs for
  108. X   MSDOS. Dan Lanciani wrote the original modifications to ARC's
  109. X   Crunch code to handle Squashing. I've made minor changes since
  110. X   then, mostly to reduce the amount of memory required. The 'q'
  111. X   option flag must be specified to Squash files. The Squashing
  112. X   algorithm will be used instead of the usual Crunch algorithm,
  113. X   and will be compared against packing and squeezing, as before.
  114. XSystem specific notes:
  115. X   On MTS, an additional option flag, 'i' for "image mode," was
  116. Xused. ARC assumes files are text, by default, and will translate
  117. XMTS files from EBCDIC to ASCII before storing in an archive, and
  118. Xtranslates from ASCII to EBCDIC upon extraction. Specifying the
  119. X'i' flag will inhibit this translation. This would most commonly
  120. Xbe used when shipping binary images such as TeX DVI files, other
  121. X.ARC files stored within an archive, etc... The 'r' (run) command
  122. Xis omitted. It just doesn't seem very useful. Also, ARC cannot
  123. Xrestore MTS files with their original time stamps. (Maybe in a
  124. Xfuture release...)
  125. X   On Unix(tm) systems, the 'i' flag is also present. Unix ARC
  126. Xassumes a binary file, by default. Here the only translation
  127. Xinvolved is in end-of-line processing. When storing text files, ARC will
  128. Xchange '\n' to '\r\n', and does the opposite when extracting files.
  129. XCarriage returns in any other location are preserved when extracting.
  130. XThis translation only occurs if the 'i' flag is given.
  131. X
  132. X   On the Atari ST, the 'h' (for "hold screen") option is present,
  133. Xwhich simply delays exiting the program. This is typically used when
  134. Xexecuting ARC from the desktop, to allow reading all of ARC's output
  135. Xbefore the screen is cleared and the desktop is redrawn. The program
  136. Xwill prompt and wait for a keypress before exiting. Note that since
  137. Xthere are no "options" for the MARC program, the "hold screen" option
  138. Xis always active for MARC.
  139. X   On both Unix and Atari systems, ARC & MARC will search for an
  140. Xenvironment variable named "ARCTEMP" or "TMPDIR." If present, any
  141. Xtemporary files will be created in the specified directory. This is
  142. Xprobably insignificant for Unix users, but can be handy on the Atari,
  143. Xin combination with a RAMdisk. Highly recommended for floppy users.
  144. X(Unfortunately, you can only take advantage of this when running some
  145. Xform of command shell that allows setting environment variables. Thus,
  146. Xyou won't see any speed gains when running from the desktop.)
  147. XThat about covers things. The enclosed documentation is taken directly
  148. Xfrom the MSDOS distribution of ARC. Unless specified differently here,
  149. Xthe programs behave indentically. Note that ARC521.DOC is identical to
  150. XARC520.DOC - the differences between the two versions are described in
  151. Xthe file CHANGES.521.
  152. XOh yeah - this program may be distributed freely so long as you don't
  153. Xmodify it in any way. You may not charge for distributing it. (Don't
  154. Xfeel bad, I can't charge for it either. }-) It'd be nice if you kept
  155. Xthis and the other enclosed doc files with it when distributing, but
  156. XI'm not going to make a fuss about it. Most people are so familiar
  157. Xwith the program by now that it wouldn't matter much anyway. You
  158. Xshould keep this README file around, so bug reports & such will find
  159. Xtheir way back to me. (Bugs? What bugs? Nah, there aren't any bugs...)
  160. X         /                 Howard Chu
  161. X   ___  /_ , ,_.     University of Michigan
  162. X       / /(_/(__     hyc@umix.cc.umich.edu
  163. X           /                umix!hyc
  164. X          '     
  165. ________This_Is_The_END________
  166. if test `wc -c < Readme.too` -ne     4064; then
  167.     echo 'shar: Readme.too was damaged during transit (should have been     4064 bytes)'
  168. fi
  169. fi        ; : end of overwriting check
  170. echo 'x - Manifest'
  171. if test -f Manifest; then echo 'shar: not overwriting Manifest'; else
  172. sed 's/^X//' << '________This_Is_The_END________' > Manifest
  173. XContents of this distribution....
  174. X   5577 Apr 11 19:15 Arcinfo       Description of .ARC file format
  175. X  54144 Jun 13 05:26 Arc521.doc       Full program documentation, no CRs.
  176. X   1892 May 14  1987 Changes.521   Differences between 5.20 and 5.21
  177. X   1323 Apr 11 19:10 Make.tws       Makefile for the time routine library
  178. X   1731 Jun 13 03:58 Makefile       Makefile for ARC
  179. X   2413 Jun 13 05:29 Manifest       This file
  180. X   2269 Jun 18 03:39 Read.me       Spiel
  181. X   2190 Jun 13 04:23 Readme.too       More spiel
  182. X  18327 Jun 13 04:09 Sysvarcstuf   Useful for Sys V users.
  183. X   7232 Jun 12 19:31 arc.1       A man page, *roff source
  184. X  11116 Jun 13 04:27 arc.c       Main routine, option parser...
  185. X   3318 Jun  1 19:59 arc.h       System dependencies, externs
  186. X   9286 Jun 13 00:31 arcadd.c       Top level routine for adding to archive
  187. X   1204 Jun  1 15:16 arccode.c       Code for file encryption/decryption
  188. X   3396 Jun  1 19:18 arccvt.c       Convert to new packing method
  189. X   2070 Jun 13 04:26 arcdata.c       Declarations of externs from arc.h
  190. X   2055 Apr 19 01:39 arcdel.c       Delete files from archive
  191. X   4970 Jun 13 00:41 arcdos.c       OS specific file management routines
  192. X   4897 Jun  1 20:18 arcext.c       Top level routine for extraction
  193. X   7384 Jun  2 16:27 arcio.c       OS specific low-level I/O routines
  194. X   4418 Jun  1 18:06 arclst.c       List contents of archive
  195. X  22109 Jun  1 20:01 arclzw.c       Low-level Lempel-Zev compression
  196. X   3026 Jun  1 19:41 arcmatch.c       Pattern matching routines
  197. X   8319 Jun 13 04:07 arcmisc.c       OS specific miscellaneous functions
  198. X   7376 Jun  2 16:27 arcpack.c       Mid-level compression code
  199. X   3838 Jun  1 19:57 arcrun.c       Run files from archive
  200. X   1645 Apr 17 18:53 arcs.h       Declaration of .ARC header format
  201. X  14613 Jun  2 16:27 arcsq.c       Low-level Huffman Squeeze code
  202. X  11587 Jun  1 20:02 arcsqs.c       Low-level Squash code
  203. X   4680 Jun 13 00:43 arcsvc.c       .ARC file utilities
  204. X   1284 Apr 19 01:40 arctst.c       Test archive integrity
  205. X   5325 Jun  7 03:16 arcunp.c       Mid-level extraction code
  206. X   2484 Jun  2 16:28 arcusq.c       Low-level Huffman unSqueezer
  207. X   9035 Apr 11 19:10 dtime.c       sources for the time routine library...
  208. X   7327 Apr 11 19:11 dtimep.lex
  209. X    356 Apr 11 19:12 lexedit.sed
  210. X   3765 Apr 11 19:12 lexstring.c
  211. X   2241 Apr 11 19:13 libtws.3       man page for the time routine library
  212. X   9053 Jun  6 01:04 marc.c       source for the marc program
  213. X   2993 Jun  2 00:38 tws.h       header file for the time routine library
  214. ________This_Is_The_END________
  215. if test `wc -c < Manifest` -ne     2413; then
  216.     echo 'shar: Manifest was damaged during transit (should have been     2413 bytes)'
  217. fi
  218. fi        ; : end of overwriting check
  219. echo 'x - Make.tws'
  220. if test -f Make.tws; then echo 'shar: not overwriting Make.tws'; else
  221. sed 's/^X//' << '________This_Is_The_END________' > Make.tws
  222. X# Makefile for phoon, deltime, parsetime, and libtws (stolen from mh).
  223. X
  224. X# Valid options:
  225. X#   BSD42      Set this if your system is BSD 4.2 or later.
  226. X#   SYS5       Set this if your system is System V.
  227. X#   EUROPE     Makes nn/nn/nn mean dd/mm/yy instead of mm/dd/yy.
  228. X#   ATZ        This has something to do with alpha-numeric time zones.
  229. X#   DSTXXX     This has something to do with daylight savings time.
  230. X#   HUJI       I don't
  231. X#   INETONLY           know what
  232. X#   LEXDEBUG                     the rest of these
  233. X#   ONECASE                                        do.
  234. X#
  235. X# Original posted to mod.sources by Jef Poskanzer. Cannibalized for use
  236. X# with ARC by Howard Chu.
  237. XOPTIONS    =    -DBSD42 -DATZ -DDSTXXX -DONECASE
  238. X
  239. X
  240. XCC      =    cc
  241. XCFLAGS  =    -O $(OPTIONS)
  242. XLDFLAGS =    -ns
  243. X
  244. Xlibtws.a:    dtime.o dtimep.o lexstring.o
  245. X        ar r libtws.a dtime.o dtimep.o lexstring.o
  246. X# The following amusing bullshit makes sure that ranlib
  247. X# gets executed if it is present, no matter which shell
  248. X# make uses.  If there's a better way to do this, someone
  249. X# please tell me!
  250. X        -if test -r /usr/bin/ranlib ; then ranlib libtws.a ; fi
  251. X        -if ( -r /usr/bin/ranlib ) ranlib libtws.a
  252. X
  253. Xdtime.o:    dtime.c tws.h
  254. X
  255. Xdtimep.o:    dtimep.c tws.h
  256. X
  257. Xdtimep.c:    dtimep.lex
  258. X        lex -nt dtimep.lex | sed -f lexedit.sed > dtimep.c
  259. X
  260. Xlexstring.o:    lexstring.c
  261. X        $(CC) $(CFLAGS) -c lexstring.c
  262. ________This_Is_The_END________
  263. if test `wc -c < Make.tws` -ne     1323; then
  264.     echo 'shar: Make.tws was damaged during transit (should have been     1323 bytes)'
  265. fi
  266. fi        ; : end of overwriting check
  267. echo 'x - Makefile'
  268. if test -f Makefile; then echo 'shar: not overwriting Makefile'; else
  269. sed 's/^X//' << '________This_Is_The_END________' > Makefile
  270. X#
  271. X#       Makefile for Hack-attack 1.3
  272. X#       VAX 11/780 BSD4.2 "ARC" utility
  273. X#
  274. X# Originals from Dan Lanciani, James Turner, and others...
  275. X#
  276. X# Modified to support squashing, also added targets for the time routine
  277. X# library.  -- Howard Chu, hyc@umix.cc.umich.edu, 4-11-88
  278. X#
  279. X# I put SRCDIR on a real disk on the ST, but copy the makefile to a
  280. X# RAMdisk and compile from there. Makes things go a bit quicker...
  281. X# This has to be done in the shell, to get the trailing backslash
  282. X# specified correctly. e.g., setenv SRCDIR='d:\src\arc\'
  283. XSRCDIR = 
  284. X
  285. XHEADER = $(SRCDIR)arc.h
  286. X
  287. X# Add a ".TTP" suffix to the executable files on an ST.
  288. X#PROG = .ttp
  289. XPROG =
  290. X
  291. X# TWSLIB is only needed on Unix systems. Likewise for TWHEAD.
  292. X#TWSLIB =
  293. X#TWHEAD =
  294. XTWSLIB = libtws.a
  295. XTWHEAD = tws.h
  296. X
  297. X# For MWC 3.0 on the Atari ST, use:
  298. X#CFLAGS = -VCOMPAC -VPEEP
  299. XCFLAGS = -O
  300. X
  301. XOBJS = arc.o arcadd.o arccode.o arccvt.o arcdata.o arcdel.o arcdos.o \
  302. Xarcext.o arcio.o arclst.o arclzw.o arcmatch.o arcpack.o arcrun.o \
  303. Xarcsq.o arcsqs.o arcsvc.o arctst.o arcunp.o arcusq.o arcmisc.o
  304. X
  305. XMOBJ = marc.o arcdata.o arcdos.o arcio.o arcmatch.o arcmisc.o
  306. X
  307. Xarc$(PROG):    $(OBJS) $(TWSLIB)
  308. X    cc -o arc$(PROG) $(OBJS) $(TWSLIB)
  309. X
  310. Xmarc$(PROG):    $(MOBJ) $(TWSLIB)
  311. X    cc -o marc$(PROG) $(MOBJ) $(TWSLIB)
  312. X
  313. Xclean:
  314. X    -rm *.o arc$(PROG) marc$(PROG) $(TWSLIB)
  315. X
  316. X$(HEADER):    $(SRCDIR)arcs.h
  317. X    touch $(HEADER)
  318. X
  319. Xarc.o:    $(HEADER)
  320. X    cc $(CFLAGS) -c $(SRCDIR)arc.c
  321. Xmarc.o:    $(HEADER)
  322. X    cc $(CFLAGS) -c $(SRCDIR)marc.c
  323. Xarcadd.o:    $(HEADER)
  324. X    cc $(CFLAGS) -c $(SRCDIR)arcadd.c
  325. Xarccode.o:    $(HEADER)
  326. X    cc $(CFLAGS) -c $(SRCDIR)arccode.c
  327. Xarccvt.o:    $(HEADER)
  328. X    cc $(CFLAGS) -c $(SRCDIR)arccvt.c
  329. Xarcdata.o:    $(HEADER)
  330. X    cc $(CFLAGS) -c $(SRCDIR)arcdata.c
  331. Xarcdel.o:    $(HEADER)
  332. X    cc $(CFLAGS) -c $(SRCDIR)arcdel.c
  333. Xarcdir.o:    $(HEADER)
  334. X    cc $(CFLAGS) -c $(SRCDIR)arcdir.c
  335. Xarcdos.o:    $(HEADER) $(TWHEAD)
  336. X    cc $(CFLAGS) -c $(SRCDIR)arcdos.c
  337. Xarcext.o:    $(HEADER)
  338. X    cc $(CFLAGS) -c $(SRCDIR)arcext.c
  339. Xarcio.o:    $(HEADER)
  340. X    cc $(CFLAGS) -c $(SRCDIR)arcio.c
  341. Xarclst.o:    $(HEADER)
  342. X    cc $(CFLAGS) -c $(SRCDIR)arclst.c
  343. Xarclzw.o:    $(HEADER)
  344. X    cc $(CFLAGS) -c $(SRCDIR)arclzw.c
  345. Xarcmatch.o:    $(HEADER)
  346. X    cc $(CFLAGS) -c $(SRCDIR)arcmatch.c
  347. Xarcmisc.o:    $(HEADER)
  348. X    cc $(CFLAGS) -c $(SRCDIR)arcmisc.c
  349. Xarcpack.o:    $(HEADER)
  350. X    cc $(CFLAGS) -c $(SRCDIR)arcpack.c
  351. Xarcrun.o:    $(HEADER)
  352. X    cc $(CFLAGS) -c $(SRCDIR)arcrun.c
  353. Xarcsq.o:    $(HEADER)
  354. X    cc $(CFLAGS) -c $(SRCDIR)arcsq.c
  355. Xarcsqs.o:    $(HEADER)
  356. X    cc $(CFLAGS) -c $(SRCDIR)arcsqs.c
  357. Xarcsvc.o:    $(HEADER)
  358. X    cc $(CFLAGS) -c $(SRCDIR)arcsvc.c
  359. Xarctst.o:    $(HEADER)
  360. X    cc $(CFLAGS) -c $(SRCDIR)arctst.c
  361. Xarcunp.o:    $(HEADER)
  362. X    cc $(CFLAGS) -c $(SRCDIR)arcunp.c
  363. Xarcusq.o:    $(HEADER)
  364. X    cc $(CFLAGS) -c $(SRCDIR)arcusq.c
  365. X
  366. Xlibtws.a:
  367. X    make -f Make.tws libtws.a
  368. ________This_Is_The_END________
  369. if test `wc -c < Makefile` -ne     2644; then
  370.     echo 'shar: Makefile was damaged during transit (should have been     2644 bytes)'
  371. fi
  372. fi        ; : end of overwriting check
  373. echo 'x - Changes.521'
  374. if test -f Changes.521; then echo 'shar: not overwriting Changes.521'; else
  375. sed 's/^X//' << '________This_Is_The_END________' > Changes.521
  376. X                        CHANGES IN VERSION 5.21
  377. X
  378. X
  379. XThe following changes have been made in ARC version 5.21, but have not
  380. Xyet been included in the manual:
  381. X
  382. Xo   When adding files to an archive, ARC now shows the stowage facter
  383. X    achieved on each file.
  384. X
  385. Xo   A bug was found that would keep an archive entry from being
  386. X    encrypted if it was stored without compression.  This has now been
  387. X    fixed.
  388. X
  389. Xo   If changes are made to a corrupted archive, the corrupted entries
  390. X    are discarded.  This makes it possible to lose data accidentally.
  391. X    ARC will now only make changes to a corrupted archive if the W
  392. X    (suppress Warnings) option has been given.
  393. X
  394. Xo   The N (suppress Notes) option now suppresses the "Creating
  395. X    archive" note when a new archive is being created.
  396. X
  397. Xo   The N (suppress Notes) option formerly did nothing useful when
  398. X    used with the L (List files) command.  It now causes a terse
  399. X    listing of filenames only, suitable for use with pipes and
  400. X    redirection.
  401. X
  402. Xo   The list of filenames given to ARC may now include indirect
  403. X    references.  If a filename begins with an "at sign" ("@"), it is
  404. X    taken to be the name of a file which contains a list of file
  405. X    names.  The list of file names may include further indirection.
  406. X    If no extension is given, ".CMD" is assumed.  For example, the
  407. X    command:
  408. X
  409. X         arc a waste junk.txt @trash
  410. X
  411. X    would cause ARC to add JUNK.TXT plus all files listed in the file
  412. X    TRASH.CMD to an archive named WASTE.ARC.  If no file is specified,
  413. X    then the list is read from standard input.  For example, the
  414. X    command:
  415. X
  416. X         arc ln waste | arc a trash @
  417. X
  418. X    would cause ARC to add files to TRASH.ARC based on the names of
  419. X    the files stored in WASTE.ARC.  It is probably a good idea to give
  420. X    the O (Overwrite) option if you are extracting files this way.
  421. X
  422. X    Version 5.21 of MARC also allows for indirection.
  423. ________This_Is_The_END________
  424. if test `wc -c < Changes.521` -ne     1892; then
  425.     echo 'shar: Changes.521 was damaged during transit (should have been     1892 bytes)'
  426. fi
  427. fi        ; : end of overwriting check
  428. echo 'x - Arcinfo'
  429. if test -f Arcinfo; then echo 'shar: not overwriting Arcinfo'; else
  430. sed 's/^X//' << '________This_Is_The_END________' > Arcinfo
  431. X
  432. XARC-FILE.INF, created by Keith Petersen, W8SDZ, 21-Sep-86, extracted
  433. Xfrom UNARC.INF by Robert A. Freed.
  434. X
  435. XFrom:     Robert A. Freed
  436. XSubject:  Technical Information for ARC files
  437. XDate:     June 24, 1986
  438. X
  439. XNote: In the following discussion, UNARC refers to my CP/M-80 program
  440. Xfor extracting files from MSDOS ARCs.  The definitions of the ARC file
  441. Xformat are based on MSDOS ARC512.EXE.
  442. X
  443. XARCHIVE FILE FORMAT
  444. X-------------------
  445. X
  446. XComponent files are stored sequentially within an archive.  Each entry
  447. Xis preceded by a 29-byte header, which contains the directory
  448. Xinformation.  There is no wasted space between entries.  (This is in
  449. Xcontrast to the centralized directory used by Novosielski libraries.
  450. XAlthough random access to subfiles within an archive can be noticeably
  451. Xslower than with libraries, archives do have the advantage of not
  452. Xrequiring pre-allocation of directory space.)
  453. X
  454. XArchive entries are normally maintained in sorted name order.  The
  455. Xformat of the 29-byte archive header is as follows:
  456. X
  457. XByte 1:  1A Hex.
  458. X         This marks the start of an archive header.  If this byte is not found 
  459. X         when expected, UNARC will scan forward in the file (up to 64K bytes) 
  460. X         in an attempt to find it (followed by a valid compression version).  
  461. X         If a valid header is found in this manner, a warning message is 
  462. X         issued and archive file processing continues.  Otherwise, the file is 
  463. X         assumed to be an invalid archive and processing is aborted.  (This is 
  464. X         compatible with MS-DOS ARC version 5.12).  Note that a special 
  465. X         exception is made at the beginning of an archive file, to accomodate 
  466. X         "self-unpacking" archives (see below).
  467. X
  468. XByte 2:  Compression version, as follows:
  469. X
  470. X         0 = end of file marker (remaining bytes not present)
  471. X         1 = unpacked (obsolete)
  472. X         2 = unpacked
  473. X         3 = packed
  474. X         4 = squeezed (after packing)
  475. X         5 = crunched (obsolete)
  476. X         6 = crunched (after packing) (obsolete)
  477. X         7 = crunched (after packing, using faster hash algorithm) (obsolete)
  478. X         8 = crunched (after packing, using dynamic LZW variations)
  479. X
  480. XBytes 3-15:  ASCII file name, nul-terminated.
  481. X
  482. X(All of the following numeric values are stored low-byte first.)
  483. X
  484. XBytes 16-19:  Compressed file size in bytes.
  485. X
  486. XBytes 20-21:  File date, in 16-bit MS-DOS format:
  487. X              Bits 15:9 = year - 1980
  488. X              Bits  8:5 = month of year
  489. X              Bits  4:0 = day of month
  490. X              (All zero means no date.)
  491. X
  492. XBytes 22-23:  File time, in 16-bit MS-DOS format:
  493. X              Bits 15:11 = hour (24-hour clock)
  494. X              Bits 10:5  = minute
  495. X              Bits  4:0  = second/2 (not displayed by UNARC)
  496. X
  497. XBytes 24-25:  Cyclic redundancy check (CRC) value (see below).
  498. X
  499. XBytes 26-29:  Original (uncompressed) file length in bytes.
  500. X              (This field is not present for version 1 entries, byte 2 = 1.  
  501. X              I.e., in this case the header is only 25 bytes long.  Because 
  502. X              version 1 files are uncompressed, the value normally found in 
  503. X              this field may be obtained from bytes 16-19.)
  504. X
  505. X
  506. XSELF-UNPACKING ARCHIVES
  507. X-----------------------
  508. X
  509. XA "self-unpacking" archive is one which can be renamed to a .COM file
  510. Xand executed as a program.  An example of such a file is the MS-DOS
  511. Xprogram ARC512.COM, which is a standard archive file preceded by a
  512. Xthree-byte jump instruction.  The first entry in this file is a simple
  513. X"bootstrap" program in uncompressed form, which loads the subfile
  514. XARC.EXE (also uncompressed) into memory and passes control to it.  In
  515. Xanticipation of a similar scheme for future distribution of UNARC, the
  516. Xprogram permits up to three bytes to precede the first header in an
  517. Xarchive file (with no error message).
  518. X
  519. X
  520. XCRC COMPUTATION
  521. X---------------
  522. X
  523. XArchive files use a 16-bit cyclic redundancy check (CRC) for error
  524. Xcontrol.  The particular CRC polynomial used is x^16 + x^15 + x^2 + 1,
  525. Xwhich is commonly known as "CRC-16" and is used in many data
  526. Xtransmission protocols (e.g. DEC DDCMP and IBM BSC), as well as by
  527. Xmost floppy disk controllers.  Note that this differs from the CCITT
  528. Xpolynomial (x^16 + x^12 + x^5 + 1), which is used by the XMODEM-CRC
  529. Xprotocol and the public domain CHEK program (although these do not
  530. Xadhere strictly to the CCITT standard).  The MS-DOS ARC program does
  531. Xperform a mathematically sound and accurate CRC calculation.  (We
  532. Xmention this because it contrasts with some unfortunately popular
  533. Xpublic domain programs we have witnessed, which from time immemorial
  534. Xhave based their calculation on an obscure magazine article which
  535. Xcontained a typographical error!)
  536. X
  537. XAdditional note (while we are on the subject of CRC's): The validity
  538. Xof using a 16-bit CRC for checking an entire file is somewhat
  539. Xquestionable.  Many people quote the statistics related to these
  540. Xfunctions (e.g. "all two-bit errors, all single burst errors of 16 or
  541. Xfewer bits, 99.997% of all single 17-bit burst errors, etc."), without
  542. Xrealizing that these claims are valid only if the total number of bits
  543. Xchecked is less than 32767 (which is why they are used in small-packet
  544. Xdata transmission protocols).  I.e., for file sizes in excess of about
  545. X4K bytes, a 16-bit CRC is not really as good as what is often claimed.
  546. XThis is not to say that it is bad, but there are more reliable methods
  547. Xavailable (e.g. the 32-bit AUTODIN-II polynomial).  (End of lecture!)
  548. X
  549. X                           Bob Freed
  550. X                           62 Miller Road
  551. X                           Newton Centre, MA  02159
  552. X                           Telephone (617) 332-3533
  553. X
  554. X
  555. ________This_Is_The_END________
  556. if test `wc -c < Arcinfo` -ne     5577; then
  557.     echo 'shar: Arcinfo was damaged during transit (should have been     5577 bytes)'
  558. fi
  559. fi        ; : end of overwriting check
  560. echo 'x - Sysvarcstuf'
  561. if test -f Sysvarcstuf; then echo 'shar: not overwriting Sysvarcstuf'; else
  562. sed 's/^X//' << '________This_Is_The_END________' > Sysvarcstuf
  563. XTo: Howard_Chu%um.cc.umich.edu%umix.uucp@umix.cc.umich.edu
  564. XDate: Fri, 15 Apr 88 19:12:24 EST
  565. XFrom: Jon Zeeff <zeeff%b-tech.UUCP@umix.cc.umich.edu>
  566. XIn-Reply-To: Message from "um.cc.umich.edu!Howard_Chu" of Apr 15
  567. XX-Mailer: Elm [version 1.7]
  568. XMessage-Id: <8804151912.AA00417@b-tech.UUCP>
  569. XHere is what I believe to be all the routines needed to run your arc on
  570. XSys V.3.  Sys V.2 people will also need the directory routines that
  571. Xwere posted in comp.sources.unix Vol 9 as gwyn-dir-lib.
  572. X#! /bin/sh
  573. X# This is a shell archive.  Remove anything before this line, then unpack
  574. X# it by saving it into a file and typing "sh file".  To overwrite existing
  575. X# files, type "sh file -c".  You can also feed this as standard input via
  576. X# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  577. X# will see the following message at the end:
  578. X#             "End of shell archive."
  579. X# Contents:  getwd.c scandir.sh utimes.c
  580. X# Wrapped by root@b-tech on Fri Apr 15 19:05:49 1988
  581. XPATH=/bin:/usr/bin:/usr/ucb ; export PATH
  582. Xif test -f getwd.c -a "${1}" != "-c" ; then
  583. X  echo shar: Will not over-write existing file \"getwd.c\"
  584. Xelse
  585. Xecho shar: Extracting \"getwd.c\" \(726 characters\)
  586. Xsed "s/^X//" >getwd.c <<'END_OF_getwd.c'
  587. XX/*
  588. XX * 4.2bsd getwd simulation for Sys V.3
  589. XX */
  590. XX
  591. XX#include <stdio.h>
  592. XX
  593. XX#define SYSV3
  594. XX
  595. XX#define MAXWD 1024           /* limited by 4.2 getwd(2) */
  596. XX
  597. XX#ifdef SYSV3
  598. XX
  599. XXchar *getcwd();
  600. XX
  601. XXchar *
  602. XXgetwd(path)
  603. XXchar *path;
  604. XX{
  605. XX    return(getcwd(path,MAXWD));
  606. XX}
  607. XX
  608. XX#else
  609. XX
  610. XX/*
  611. XX * 4.2bsd getwd simulation for Sys V.2
  612. XX */
  613. XX
  614. XX#include <stdio.h>
  615. XX
  616. XX#define MAXWD 1024           /* limited by 4.2 getwd(2) */
  617. XX
  618. XXchar *
  619. XXgetwd(path)
  620. XXchar *path;
  621. XX{
  622. XX     char *nlp;
  623. XX     FILE *fp;
  624. XX     FILE *popen();
  625. XX     char *strrchr();
  626. XX
  627. XX        putenv("IFS= \t\n");
  628. XX     fp = popen("PATH=/bin:/usr/bin pwd", "r");
  629. XX     if (fp == NULL)
  630. XX             return 0;
  631. XX     if (fgets(path, MAXWD, fp) == NULL) {
  632. XX             (void) pclose(fp);
  633. XX             return 0;
  634. XX     }
  635. XX     if ((nlp = strrchr(path, '\n')) != NULL)
  636. XX             *nlp = '\0';
  637. XX     (void) pclose(fp);
  638. XX     return path;
  639. XX}
  640. XX#endif
  641. XX
  642. XEND_OF_getwd.c
  643. Xif test 726 -ne `wc -c <getwd.c`; then
  644. X    echo shar: \"getwd.c\" unpacked with wrong size!
  645. Xfi
  646. X# end of overwriting check
  647. Xfi
  648. Xif test -f scandir.sh -a "${1}" != "-c" ; then
  649. X  echo shar: Will not over-write existing file \"scandir.sh\"
  650. Xelse
  651. Xecho shar: Extracting \"scandir.sh\" \(13502 characters\)
  652. Xsed "s/^X//" >scandir.sh <<'END_OF_scandir.sh'
  653. XXPath: uunet!husc6!hao!oddjob!gargoyle!ihnp4!cbosgd!mandrill!hal!ncoast!allbery
  654. XXFrom: rsalz@pebbles.bbn.com
  655. XXNewsgroups: comp.sources.misc
  656. XXSubject: scandir, ftw REDUX
  657. XXMessage-ID: <6943@ncoast.UUCP>
  658. XXDate: 1 Jan 88 00:47:01 GMT
  659. XXSender: allbery@ncoast.UUCP
  660. XXLines: 505
  661. XXApproved: allbery@ncoast.UUCP
  662. XXX-Archive: comp.sources.misc/8712/15
  663. XX
  664. XXForget my previous message -- I just decided for completeness's sake to
  665. XXimplement the SysV ftw(3) routine, too.
  666. XX
  667. XXTo repeat, these are public-domain implementations of the SystemV ftw()
  668. XXroutine, the BSD scandir() and alphasort() routines, and documentation for
  669. XXsame.  The FTW manpage could be more readable, but so it goes.
  670. XX
  671. XXAnyhow, feel free to post these, and incorporate them into your existing
  672. XXpackages.  I have readdir() routiens for MSDOS and the Amiga if anyone
  673. XXwants them, and should have them for VMS by the end of January; let me
  674. XXknow if you want copies.
  675. XX
  676. XXYours in filesystems,
  677. XX     /r$
  678. XX
  679. XXAnyhow, feel free to post
  680. XX#! /bin/sh
  681. XX# This is a shell archive.  Remove anything before this line, then unpack
  682. XX# it by saving it into a file and typing "sh file".  To overwrite existing
  683. XX# files, type "sh file -c".  You can also feed this as standard input via
  684. XX# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  685. XX# will see the following message at the end:
  686. XX#            "End of shell archive."
  687. XX# Contents:  alphasort.c ftw.3 ftw.c ftw.h scandir.3 scandir.c
  688. XX# Wrapped by rsalz@fig.bbn.com on Tue Dec 29 21:39:01 1987
  689. XXPATH=/bin:/usr/bin:/usr/ucb ; export PATH
  690. XXif test -f 'alphasort.c' -a "${1}" != "-c" ; then
  691. XX  echo shar: Will not clobber existing file \"'alphasort.c'\"
  692. XXelse
  693. XXecho shar: Extracting \"'alphasort.c'\" \(425 characters\)
  694. XXsed "s/^X//" >'alphasort.c' <<'END_OF_FILE'
  695. XXX/*
  696. XXX**  ALPHASORT
  697. XXX**  Trivial sorting predicate for scandir; puts entries in alphabetical order.
  698. XXX*/
  699. XXX#include <sys/types.h>
  700. XXX#include <sys/dir.h>
  701. XXX#ifdef      RCSID
  702. XXXstatic char RCS[] = "$Header: alphasort.c,v 1.1 87/12/29 21:35:59 rsalz Exp $";
  703. XXX#endif      /* RCSID */
  704. XXX
  705. XXX/* A convenient shorthand. */
  706. XXXtypedef struct direct        ENTRY;
  707. XXX
  708. XXXint
  709. XXXalphasort(d1, d2)
  710. XXX    ENTRY   **d1;
  711. XXX    ENTRY   **d2;
  712. XXX{
  713. XXX    return(strcmp(d1[0]->d_name, d2[0]->d_name));
  714. XXX}
  715. XXEND_OF_FILE
  716. XXif test 425 -ne `wc -c <'alphasort.c'`; then
  717. XX    echo shar: \"'alphasort.c'\" unpacked with wrong size!
  718. XXfi
  719. XX# end of 'alphasort.c'
  720. XXfi
  721. XXif test -f 'ftw.3' -a "${1}" != "-c" ; then
  722. XX  echo shar: Will not clobber existing file \"'ftw.3'\"
  723. XXelse
  724. XXecho shar: Extracting \"'ftw.3'\" \(2139 characters\)
  725. XXsed "s/^X//" >'ftw.3' <<'END_OF_FILE'
  726. XXX.TH FTW 3
  727. XXX.\" $Header: ftw.3,v 1.1 87/12/29 21:34:29 rsalz Exp $
  728. XXX.SH NAME
  729. XXXftw \- walk a file tree
  730. XXX.SH SYNOPSIS
  731. XXX.ft B
  732. XXX.nf
  733. XXX#include <ftw.h>
  734. XXX
  735. XXXint
  736. XXXftw(directory, funcptr, depth)
  737. XXX    char *directory;
  738. XXX    int (*funcptr)();
  739. XXX    int depth;
  740. XXX
  741. XXX#include <sys/stat.h>
  742. XXX
  743. XXXint
  744. XXXfuncptr(item, sb, flag)
  745. XXX    char *item;
  746. XXX    struct stat *sb;
  747. XXX    int flag;
  748. XXX.fi
  749. XXX.ft R
  750. XXX.SH DESCRIPTION
  751. XXX.I Ftw
  752. XXXwalks through the directory tree starting from the indicated
  753. XXX.IR path .
  754. XXXFor every entry it finds in the tree, it calls the user-supplied
  755. XXX.I funcptr
  756. XXXwith the calling sequence given in the synopsis above.
  757. XXXThe first argument is the full pathname of the entry (rooted from
  758. XXXthe
  759. XXX.I directory
  760. XXXparameter given to
  761. XXX.IR ftw );
  762. XXXthe second argument is a pointer to the
  763. XXX.IR stat (2)
  764. XXXstructure for the entry;
  765. XXXand the third argument is one of the #define's in the header file.
  766. XXXThis value will be one of the following:
  767. XXX.RS
  768. XXX.ta \w'FTW_DNR  'u
  769. XXX.nf
  770. XXXFTW_F       Item is a normal file
  771. XXXFTW_D       Item is a directory
  772. XXXFTW_NS      The stat failed on the item
  773. XXXFTW_DNR     Item is a directory which can't be read
  774. XXX.fi
  775. XXX.RE
  776. XXXNote, however, that FTW_F is a misnomer; anything other than directories
  777. XXXare (e.g., symbolic links) get the FTW_F tag.
  778. XXX.PP
  779. XXX.I Ftw
  780. XXXrecursively calls itself when it encounters a directory.
  781. XXXTo avoid using up all a program's file descriptors, the
  782. XXX.I depth
  783. XXXargument specifies the number of simultaneous open directories to maintain.
  784. XXXWhen the depth is exceeded, the routine will become noticeably
  785. XXXslower because directories are closed in ``most-recently-used'' order.
  786. XXX.PP
  787. XXXTo stop the tree walk, the user-supplied function should return a
  788. XXXnon\-zero value; this value will become the return value of
  789. XXX.IR ftw .
  790. XXXOtherwise,
  791. XXX.I ftw
  792. XXXwill continue until it has scanned the entire tree, in which case it will
  793. XXXreturn zero, or until it hits an error such as a
  794. XXX.IR malloc (3)
  795. XXXfailure, in which case it will return \-1.
  796. XXX.PP
  797. XXXBecause
  798. XXX.I ftw
  799. XXXuses dynamic data structures, the only safe way to exit out of a tree
  800. XXXwalk is to return a non-zero value.
  801. XXXTo handle interrupts, for example, mark that the interrupt occured
  802. XXXand return a non\-zero value\(em don't use
  803. XXX.I longjmp (3)
  804. XXXunless the program is going to terminate.
  805. XXX.SH SEE ALSO
  806. XXXstat(2)
  807. XXEND_OF_FILE
  808. XXif test 2139 -ne `wc -c <'ftw.3'`; then
  809. XX    echo shar: \"'ftw.3'\" unpacked with wrong size!
  810. XXfi
  811. XX# end of 'ftw.3'
  812. XXfi
  813. XXif test -f 'ftw.c' -a "${1}" != "-c" ; then
  814. XX  echo shar: Will not clobber existing file \"'ftw.c'\"
  815. XXelse
  816. XXecho shar: Extracting \"'ftw.c'\" \(2455 characters\)
  817. XXsed "s/^X//" >'ftw.c' <<'END_OF_FILE'
  818. XXX/*
  819. XXX**  FTW
  820. XXX**  Walk a directory hierarchy from a given point, calling a user-supplied
  821. XXX**  function at each thing we find.  If we go below a specified depth,
  822. XXX**  recycle file descriptors.
  823. XXX*/
  824. XXX#include <stdio.h>
  825. XXX#include <sys/types.h>
  826. XXX#include <sys/stat.h>
  827. XXX#include <sys/dir.h>
  828. XXX#include <ftw.h>
  829. XXX#ifdef      RCSID
  830. XXXstatic char RCS[] = "$Header: ftw.c,v 1.1 87/12/29 21:38:52 rsalz Exp $";
  831. XXX#endif      /* RCSID */
  832. XXX
  833. XXX/* Handy shorthand. */
  834. XXX#define EQ(a, b)    (strcmp((a), (b)) == 0)
  835. XXX
  836. XXX/* Linked in later. */
  837. XXXextern char         *malloc();
  838. XXXextern char         *strcpy();
  839. XXX
  840. XXX
  841. XXXint
  842. XXXftw(directory, funcptr, depth)
  843. XXX    char             *directory;
  844. XXX    int                     (*funcptr)();
  845. XXX    int                       depth;
  846. XXX{
  847. XXX    register DIR     *Dp;
  848. XXX    register char    *p;
  849. XXX    register int      i;
  850. XXX    struct direct    *E;
  851. XXX    struct stat               Sb;
  852. XXX    long              seekpoint;
  853. XXX    char             *fullpath;
  854. XXX
  855. XXX    /* If can't stat, tell the user so. */
  856. XXX    if (stat(directory, &Sb) < 0)
  857. XXX    return((*funcptr)(directory, &Sb, FTW_NS));
  858. XXX
  859. XXX    /* If it's not a directory, call the user's function. */
  860. XXX    if ((Sb.st_mode & S_IFMT) != S_IFDIR)
  861. XXX    /* Saying "FTW_F" here is lying, what if this is a symlink? */
  862. XXX    return((*funcptr)(directory, &Sb, FTW_F));
  863. XXX
  864. XXX    /* Open directory; and if we can't tell the user so. */
  865. XXX    if ((Dp = opendir(directory)) == NULL)
  866. XXX    return((*funcptr)(directory, &Sb, FTW_DNR));
  867. XXX
  868. XXX    /* See if user wants to go further. */
  869. XXX    if (i = (*funcptr)(directory, &Sb, FTW_D)) {
  870. XXX    closedir(Dp);
  871. XXX    return(i);
  872. XXX    }
  873. XXX
  874. XXX    /* Get ready to hold the full paths. */
  875. XXX    i = strlen(directory);
  876. XXX    if ((fullpath = malloc(i + 1 + MAXNAMLEN + 1)) == NULL) {
  877. XXX    closedir(Dp);
  878. XXX    return(-1);
  879. XXX    }
  880. XXX    (void)strcpy(fullpath, directory);
  881. XXX    p = &fullpath[i];
  882. XXX    if (i && p[-1] != '/')
  883. XXX    *p++ = '/';
  884. XXX
  885. XXX    /* Read all entries in the directory.. */
  886. XXX    while (E = readdir(Dp))
  887. XXX    if (!EQ(E->d_name, ".") && !EQ(E->d_name, "..")) {
  888. XXX        if (depth <= 1) {
  889. XXX            /* Going too deep; checkpoint and close this directory. */
  890. XXX            seekpoint = telldir(Dp);
  891. XXX            closedir(Dp);
  892. XXX            Dp = NULL;
  893. XXX        }
  894. XXX
  895. XXX        /* Process the file. */
  896. XXX        (void)strcpy(p, E->d_name);
  897. XXX        if (i = ftw(fullpath, funcptr, depth - 1)) {
  898. XXX            /* User's finished; clean up. */
  899. XXX            free(fullpath);
  900. XXX            if (Dp)
  901. XXX                closedir(Dp);
  902. XXX            return(i);
  903. XXX        }
  904. XXX
  905. XXX        /* Reopen the directory if necessary. */
  906. XXX        if (Dp == NULL) {
  907. XXX            if ((Dp = opendir(directory)) == NULL) {
  908. XXX                /* WTF? */
  909. XXX                free(fullpath);
  910. XXX                return(-1);
  911. XXX            }
  912. XXX            seekdir(Dp, seekpoint);
  913. XXX        }
  914. XXX    }
  915. XXX
  916. XXX    /* Clean up. */
  917. XXX    free(fullpath);
  918. XXX    closedir(Dp);
  919. XXX    return(0);
  920. XXX}
  921. XXEND_OF_FILE
  922. XXif test 2455 -ne `wc -c <'ftw.c'`; then
  923. XX    echo shar: \"'ftw.c'\" unpacked with wrong size!
  924. XXfi
  925. XX# end of 'ftw.c'
  926. XXfi
  927. XXif test -f 'ftw.h' -a "${1}" != "-c" ; then
  928. XX  echo shar: Will not clobber existing file \"'ftw.h'\"
  929. XXelse
  930. XXecho shar: Extracting \"'ftw.h'\" \(358 characters\)
  931. XXsed "s/^X//" >'ftw.h' <<'END_OF_FILE'
  932. XXX/*
  933. XXX**  <FTW.H>
  934. XXX**  Header values for the third parameter to the user-supplied function
  935. XXX**  for ftw().
  936. XXX**
  937. XXX**  $Header: ftw.h,v 1.1 87/12/29 21:34:34 rsalz Exp $
  938. XXX*/
  939. XXX
  940. XXX#define FTW_NS              100     /* Something stat(2) failed on          */
  941. XXX#define FTW_DNR             200     /* Something opendir(3) failed on       */
  942. XXX#define FTW_F               300     /* A normal file                        */
  943. XXX#define FTW_D               400     /* A directory                          */
  944. XXEND_OF_FILE
  945. XXif test 358 -ne `wc -c <'ftw.h'`; then
  946. XX    echo shar: \"'ftw.h'\" unpacked with wrong size!
  947. XXfi
  948. XX# end of 'ftw.h'
  949. XXfi
  950. XXif test -f 'scandir.3' -a "${1}" != "-c" ; then
  951. XX  echo shar: Will not clobber existing file \"'scandir.3'\"
  952. XXelse
  953. XXecho shar: Extracting \"'scandir.3'\" \(2350 characters\)
  954. XXsed "s/^X//" >'scandir.3' <<'END_OF_FILE'
  955. XXX.TH SCANDIR 3
  956. XXX.\" $Header: scandir.3,v 1.1 87/12/29 21:35:54 rsalz Exp $
  957. XXX.SH NAME
  958. XXXscandir, alphasort \- scan a directory
  959. XXX.SH SYNOPSIS
  960. XXX.nf
  961. XXX.ft B
  962. XXX#include <sys/types.h>
  963. XXX#include <sys/dir.h>
  964. XXX
  965. XXXint
  966. XXXscandir(name, list, selector, sorter)
  967. XXX.in +4n
  968. XXXchar *name;
  969. XXXstruct direct ***list;
  970. XXXint (*selector)();
  971. XXXint (*sorter)();
  972. XXX.in -4n
  973. XXX
  974. XXXint
  975. XXXalphasort(d1, d2)
  976. XXX.in +4n
  977. XXXstruct direct **d1;
  978. XXXstruct direct **d2;
  979. XXX.in -4n
  980. XXX.ft R
  981. XXX.fi
  982. XXX.SH DESCRIPTION
  983. XXX.I Scandir
  984. XXXreads the directory
  985. XXX.I name
  986. XXXand builds a NULL\-terminated array of pointers to the entries found
  987. XXXin that directory.
  988. XXXThis array is put into the location pointed to by the
  989. XXX.I list
  990. XXXparameter.
  991. XXX.PP
  992. XXXIf the
  993. XXX.I selector
  994. XXXparameter is non\-NULL, it is taken to be a pointer to a function called
  995. XXXwith each entry, to determine whether or not it should be included in
  996. XXXthe returned list.
  997. XXXIf the parameter is NULL, all entries are included.
  998. XXX.PP
  999. XXXAs an added feature, the entries can be sorted (with
  1000. XXX.IR qsort (3))
  1001. XXXbefore the list is returned.
  1002. XXXIf the
  1003. XXX.I sorter
  1004. XXXparameter is non\-NULL, it is passed to qsort to use as the comparison
  1005. XXXfunction.
  1006. XXXThe
  1007. XXX.I alphasort
  1008. XXXroutine is provided to sort the array alphabetically.
  1009. XXX.PP
  1010. XXXThe array pointed to by
  1011. XXX.I list
  1012. XXXand the items it points to are all space obtained through
  1013. XXX.IR malloc (3),
  1014. XXXand their storage can be reclaimed as shown in the example below.
  1015. XXX.SH "EXAMPLE"
  1016. XXXHere is a small
  1017. XXX.IR ls (1)\-like
  1018. XXXprogram:
  1019. XXX.ne 50
  1020. XXX.RS
  1021. XXX.nf
  1022. XXX#include <stdio.h>
  1023. XXX#include <sys/types.h>
  1024. XXX#include <sys/stat.h>
  1025. XXX#include <sys/dir.h>
  1026. XXX
  1027. XXXextern int alphasort();
  1028. XXX
  1029. XXXstatic int
  1030. XXXfilesonly(e)
  1031. XXX    struct direct *e;
  1032. XXX{
  1033. XXX    struct stat sb;
  1034. XXX
  1035. XXX    return(stat(e->d_name, &sb) >= 0 && (sb.st_mode & S_IFMT) == S_IFREG);
  1036. XXX}
  1037. XXX
  1038. XXXmain(ac, av)
  1039. XXX    int ac;
  1040. XXX    char *av[];
  1041. XXX{
  1042. XXX    register int i;
  1043. XXX    register int j;
  1044. XXX    struct direct **list;
  1045. XXX
  1046. XXX    if (ac != 2) {
  1047. XXX            fprintf(stderr, "usage: %s dirname\n", av[0]);
  1048. XXX            exit(1);
  1049. XXX    }
  1050. XXX    if (chdir(av[1]) < 0) {
  1051. XXX            perror(av[1]);
  1052. XXX            exit(1);
  1053. XXX    }
  1054. XXX    if ((i = scandir(".", &list, filesonly, alphasort)) < 0) {
  1055. XXX            perror("Error reading directory");
  1056. XXX            exit(1);
  1057. XXX    }
  1058. XXX    for (j = 0; j < i; j++)
  1059. XXX            printf("%s\n", list[j]->d_name);
  1060. XXX    for (j = 0; j < i; j++)
  1061. XXX            free((char *)list[j]);
  1062. XXX    free((char *)list);
  1063. XXX    exit(0);
  1064. XXX}
  1065. XXX.fi
  1066. XXX.RE
  1067. XXX.SH "SEE ALSO"
  1068. XXXdirectory(3), qsort(3)
  1069. XXX.SH DIAGNOSTICS
  1070. XXXReturns the number of entries in the ``list,'' or \-1 if the directory
  1071. XXXcould not be opened or a memory allocation failed.
  1072. XXX.SH BUGS
  1073. XXXThe routine can be slightly wasteful of space.
  1074. XXEND_OF_FILE
  1075. XXif test 2350 -ne `wc -c <'scandir.3'`; then
  1076. XX    echo shar: \"'scandir.3'\" unpacked with wrong size!
  1077. XXfi
  1078. XX# end of 'scandir.3'
  1079. XXfi
  1080. XXif test -f 'scandir.c' -a "${1}" != "-c" ; then
  1081. XX  echo shar: Will not clobber existing file \"'scandir.c'\"
  1082. XXelse
  1083. XXecho shar: Extracting \"'scandir.c'\" \(1777 characters\)
  1084. XXsed "s/^X//" >'scandir.c' <<'END_OF_FILE'
  1085. XXX/*
  1086. XXX**  SCANDIR
  1087. XXX**  Scan a directory, collecting all (selected) items into a an array.
  1088. XXX*/
  1089. XXX#include <sys/types.h>
  1090. XXX#include <sys/dir.h>
  1091. XXX#ifdef      RCSID
  1092. XXXstatic char RCS[] = "$Header: scandir.c,v 1.1 87/12/29 21:35:56 rsalz Exp $";
  1093. XXX#endif      /* RCSID */
  1094. XXX
  1095. XXX/* Initial guess at directory size. */
  1096. XXX#define INITIAL_SIZE        20
  1097. XXX
  1098. XXX/* A convenient shorthand. */
  1099. XXXtypedef struct direct        ENTRY;
  1100. XXX
  1101. XXX/* Linked in later. */
  1102. XXXextern char         *malloc();
  1103. XXXextern char         *realloc();
  1104. XXXextern char         *strcpy();
  1105. XXX
  1106. XXX
  1107. XXXint
  1108. XXXscandir(Name, List, Selector, Sorter)
  1109. XXX    char              *Name;
  1110. XXX    ENTRY           ***List;
  1111. XXX    int                      (*Selector)();
  1112. XXX    int                      (*Sorter)();
  1113. XXX{
  1114. XXX    register ENTRY   **names;
  1115. XXX    register ENTRY    *E;
  1116. XXX    register DIR      *Dp;
  1117. XXX    register int       i;
  1118. XXX    register int       size;
  1119. XXX
  1120. XXX    /* Get initial list space and open directory. */
  1121. XXX    size = INITIAL_SIZE;
  1122. XXX    if ((names = (ENTRY **)malloc(size * sizeof names[0])) == NULL
  1123. XXX     || (Dp = opendir(Name)) == NULL)
  1124. XXX    return(-1);
  1125. XXX
  1126. XXX    /* Read entries in the directory. */
  1127. XXX    for (i = 0; E = readdir(Dp); )
  1128. XXX    if (Selector == NULL || (*Selector)(E)) {
  1129. XXX        /* User wants them all, or he wants this one. */
  1130. XXX        if (++i >= size) {
  1131. XXX            size <<= 1;
  1132. XXX            names = (ENTRY **)realloc((char *)names, size * sizeof names[0]);
  1133. XXX            if (names == NULL) {
  1134. XXX                closedir(Dp);
  1135. XXX                return(-1);
  1136. XXX            }
  1137. XXX        }
  1138. XXX
  1139. XXX        /* Copy the entry. */
  1140. XXX        if ((names[i - 1] = (ENTRY *)malloc(DIRSIZ(E))) == NULL) {
  1141. XXX            closedir(Dp);
  1142. XXX            return(-1);
  1143. XXX        }
  1144. XXX        names[i - 1]->d_ino = E->d_ino;
  1145. XXX        names[i - 1]->d_reclen = E->d_reclen;
  1146. XXX        names[i - 1]->d_namlen = E->d_namlen;
  1147. XXX        (void)strcpy(names[i - 1]->d_name, E->d_name);
  1148. XXX    }
  1149. XXX
  1150. XXX    /* Close things off. */
  1151. XXX    names[i] = NULL;
  1152. XXX    *List = names;
  1153. XXX    closedir(Dp);
  1154. XXX
  1155. XXX    /* Sort? */
  1156. XXX    if (i && Sorter)
  1157. XXX    qsort((char *)names, i, sizeof names[0], Sorter);
  1158. XXX
  1159. XXX    return(i);
  1160. XXX}
  1161. XXEND_OF_FILE
  1162. XXif test 1777 -ne `wc -c <'scandir.c'`; then
  1163. XX    echo shar: \"'scandir.c'\" unpacked with wrong size!
  1164. XXfi
  1165. XX# end of 'scandir.c'
  1166. XXfi
  1167. XXecho shar: End of shell archive.
  1168. XXexit 0
  1169. XEND_OF_scandir.sh
  1170. Xif test 13502 -ne `wc -c <scandir.sh`; then
  1171. X    echo shar: \"scandir.sh\" unpacked with wrong size!
  1172. Xfi
  1173. X# end of overwriting check
  1174. Xfi
  1175. Xif test -f utimes.c -a "${1}" != "-c" ; then
  1176. X  echo shar: Will not over-write existing file \"utimes.c\"
  1177. Xelse
  1178. Xecho shar: Extracting \"utimes.c\" \(373 characters\)
  1179. Xsed "s/^X//" >utimes.c <<'END_OF_utimes.c'
  1180. XX
  1181. XX/* bsd utimes emulation for Sys V */
  1182. XX/* by Jon Zeeff */
  1183. XX
  1184. XX#include <sys/types.h>
  1185. XX
  1186. XXstruct utimbuf {
  1187. XX     time_t  actime;
  1188. XX     time_t  modtime;
  1189. XX};
  1190. XX
  1191. XXstruct timeval {
  1192. XX     long    tv_sec;
  1193. XX     long    tv_usec;
  1194. XX};
  1195. XX
  1196. XXutimes(path,tvp)
  1197. XXchar *path;
  1198. XXstruct timeval tvp[2];
  1199. XX{
  1200. XX
  1201. XXstruct utimbuf times;
  1202. XX
  1203. XXtimes.actime = (time_t) tvp[0].tv_sec;
  1204. XXtimes.modtime = (time_t) tvp[1].tv_sec;
  1205. XX
  1206. XXreturn utime(path,times);
  1207. XX
  1208. XX}
  1209. XEND_OF_utimes.c
  1210. Xif test 373 -ne `wc -c <utimes.c`; then
  1211. X    echo shar: \"utimes.c\" unpacked with wrong size!
  1212. Xfi
  1213. X# end of overwriting check
  1214. Xfi
  1215. Xecho shar: End of shell archive.
  1216. Xexit 0
  1217. X
  1218. ________This_Is_The_END________
  1219. if test `wc -c < Sysvarcstuf` -ne    18327; then
  1220.     echo 'shar: Sysvarcstuf was damaged during transit (should have been    18327 bytes)'
  1221. fi
  1222. fi        ; : end of overwriting check
  1223. echo 'x - tws.h'
  1224. if test -f tws.h; then echo 'shar: not overwriting tws.h'; else
  1225. sed 's/^X//' << '________This_Is_The_END________' > tws.h
  1226. X/* tws.h - header file for libtws date/time library 
  1227. X   (from mod.sources, Volume 8, Issue 81.)
  1228. X
  1229. X{Second distribution of phoon, deltime, and libtws - 24feb87.
  1230. X     Jef Poskanzer, UniSoft Systems, Berkeley
  1231. X     unisoft!jef@ucbvax.Berkeley.Edu
  1232. X          ...ucbvax!unisoft!jef
  1233. X          (415)644-1230    }
  1234. X
  1235. XThis library is used to allow date stamping of files in Unix. The
  1236. Xstandard time routines in Unix do not provide routines to convert a
  1237. Xparsed time into a time(3) clock value, so.... If you don't have this
  1238. Xcode, and can't get it, take out the references to it in arcdos.c,
  1239. Xand remove the reference to tws.h and libtws.a in the Makefile.
  1240. X
  1241. X            -- Howard Chu, March 3, 1987
  1242. X               University of Michigan Computing Center
  1243. X               hyc@umix.cc.umich.edu
  1244. X               ...uunet!umix!hyc    */
  1245. X
  1246. X
  1247. X/* Definition of the tws data structure. */
  1248. X
  1249. Xstruct tws {
  1250. X    int     tw_sec;
  1251. X    int     tw_min;
  1252. X    int     tw_hour;
  1253. X
  1254. X    int     tw_mday;
  1255. X    int     tw_mon;
  1256. X    int     tw_year;
  1257. X
  1258. X    int     tw_wday;
  1259. X    int     tw_yday;
  1260. X
  1261. X    int     tw_zone;
  1262. X
  1263. X    long    tw_clock;
  1264. X
  1265. X    int     tw_flags;
  1266. X#define TW_NULL 0x0000
  1267. X#define TW_SDAY 0x0007        /* how day-of-week was determined */
  1268. X#define   TW_SNIL 0x0000    /*   not given */
  1269. X#define   TW_SEXP 0x0001    /*   explicitly given */
  1270. X#define   TW_SIMP 0x0002    /*   implicitly given */
  1271. X#define TW_DST  0x0010        /* daylight savings time */
  1272. X#define TW_ZONE 0x0020        /* use numeric timezones only */
  1273. X#define TW_JUNK 0x0040        /* date string contained junk */
  1274. X};
  1275. X
  1276. X
  1277. X/* Declarations of routines. */
  1278. X
  1279. Xvoid twscopy( );
  1280. X    /* twscopy( &totws, &fromtws ) copies a tws */
  1281. Xint twsort( );
  1282. X    /* twsort( &tws1, &tws2 ) compares two tws's: 1 means tws1 is
  1283. X       later; -1 means tws1 is earlier; 0 means they are equal */
  1284. Xlong twclock( );
  1285. X    /* twclock( &tws ) turns a tws into a time(3)-style clock value */
  1286. Xlong twjuliandate( );
  1287. X    /* twjuliandate( &tws ) returns the Julian day number of a tws */
  1288. Xlong twsubtract( );
  1289. X    /* twsubtract( &tws1, &tws2 ) returns seconds of difference */
  1290. X
  1291. X/* These routines are functionally similar to the ctime(3) routines
  1292. X   in the standard Unix library. */
  1293. Xchar *dctime( );
  1294. X    /* dctime( &tws ) returns a string for the date/time passed in */
  1295. Xstruct tws *dlocaltime( );
  1296. X    /* dlocaltime( &clock ) turns a time(3) clock value into a tws */
  1297. Xstruct tws *dgmtime( );
  1298. X    /* dgmtime( &clock ) turns a time(3) clock value into a tws */
  1299. Xchar *dasctime( );
  1300. X    /* dasctime( &tws, flags ) turns a tws into a string */
  1301. Xchar *dtimezone( );
  1302. X    /* dtimezone( offset, flags ) returns the name of the time zone */
  1303. X
  1304. Xchar *dtimenow( );
  1305. X    /* dtimenow( ) returns a string for the current date/time */
  1306. X
  1307. Xstruct tws *dparsetime( );
  1308. X    /* dparsetime( &str ) turns a string into a tws */
  1309. X
  1310. Xstruct tws *dtwstime( );
  1311. X    /* dtwstime( ) returns a tws for the current date/time */
  1312. X
  1313. X#ifdef ATZ
  1314. X#define dtime(cl) dasctime( dlocaltime( cl ), TW_NULL )
  1315. X#else
  1316. X#define dtime(cl) dasctime( dlocaltime( cl ), TW_ZONE )
  1317. X#endif
  1318. X
  1319. X#define dtwszone(tw) dtimezone( tw -> tw_zone, tw -> tw_flags )
  1320. X
  1321. X
  1322. Xextern char   *tw_dotw[], *tw_ldotw[], *tw_moty[];
  1323. ________This_Is_The_END________
  1324. if test `wc -c < tws.h` -ne     2985; then
  1325.     echo 'shar: tws.h was damaged during transit (should have been     2985 bytes)'
  1326. fi
  1327. fi        ; : end of overwriting check
  1328. exit 0
  1329.  
  1330. -- 
  1331. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  1332.  
  1333.  
  1334.